package com.example.webflux_mongo.handler;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    HelloWorldHandler
 * Author:      AmbroseCdMeng
 * Date:        2021/1/1519:28
 * Description: 处理器。相当于 MVC 中的 Controller
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */

@Component
public class HelloWorldHandler {
    public Mono<ServerResponse> sayHelloWorld(ServerRequest serverRequest) {
        return ServerResponse.ok()
                .contentType(MediaType.TEXT_PLAIN)
                .body(Mono.just("This is WebFlux demo"), String.class);
    }
}
